﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.Reputation.Tests.FrontEndCommon
{
    public partial class ReputationCategory
    {
        [Flags]
        public enum CategoryFlags
        {
            None            = 0x00000000,
            PositiveConf    = 0x10000000 << 0,
            NegativeConf    = 0x10000000 << 1,
            HostInherits    = 0x10000000 << 2,
            PathInherits    = 0x10000000 << 3,
            NoConf          = PositiveConf | NegativeConf,
            FlagsMask       = NoConf | HostInherits | PathInherits,
            CategoryMask    = 0x0FFFFFFF
        }

        public enum ConfidenceValues
        {
            None            = 50,
            Negative        = 0,
            Positive        = 100
        }

        public byte[] Pack()
        {
            CategoryFlags flags = CategoryFlags.None;
            flags |= PathInheritance ? CategoryFlags.PathInherits : CategoryFlags.None;
            flags |= HostInheritance ? CategoryFlags.HostInherits : CategoryFlags.None;
            flags |= Confidence == (int)ConfidenceValues.Negative ? CategoryFlags.NegativeConf : 
                     Confidence == (int)ConfidenceValues.Positive ? CategoryFlags.PositiveConf : CategoryFlags.NoConf;

            return BitConverter.GetBytes(CategoryId | (int)flags).Reverse().ToArray();
        }
    }
}
